const Koa=require('koa2');
const app=new Koa();
const sleep=ms=>new Promise((resolve,reject)=>{
    setTimeout(()=>{
        resolve();
    },ms);
});

app.use(async (ctx,next)=>{
    console.log('Status');
    ctx.status=200;
    await next();//
    console.log('Status End');
});

app.use(async ctx=>{
    return sleep(500).then(()=>{
        console.log('Body');
        ctx.body=new Date().toLocaleString();
        console.log('Body End');
    });
});


app.listen(3002,()=>{
    console.log('\n\nPort 3002',new Date().toLocaleTimeString());
});
